import { createRouter, createWebHistory } from 'vue-router'
import { beforeEach } from './beforeEach'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home',
      name: '重定向',
      meta: {
        title: '重定向'
      }
    },
    {
      path: '/home',
      component: () => import('@/views/home/index.vue'),
      name: 'Home',
      meta: {
        title: '首页'
      }
    },
    {
      path: '/login',
      component: () => import('../views/login/index.vue'),
      name: 'Login',
      meta: {
        title: '登录'
      }
    },
    {
      path: '/create/product',
      component: () => import('../views/create-product/index.vue'),
      name: 'CreateProduct',
      meta: {
        title: '创建作品'
      }
    },
    {
      path: '/my/product',
      component: () => import('../views/my-product/index.vue'),
      name: 'MyProduct',
      meta: {
        title: '我的作品'
      }
    },
    {
      path: '/post/:id',
      component: () => import('../views/post-detail/index.vue'),
      name: 'PostDetail',
      meta: {
        title: '模板详情'
      }
    },
    {
      path: '/workbnch',
      component: () => import('../views/workbnch/index.vue'),
      name: 'Workbnch',
      meta: {
        title: '工作台'
      }
    },
    {
      path: '/message',
      component: () => import('../views/message/index.vue'),
      name: 'message',
      meta: {
        title: '协助'
      }
    }
  ]
})

beforeEach(router)

export default router
